package com.meichis.yndms.room.converter;


import androidx.room.TypeConverter;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.meichis.mcsappframework.entity.Attachment;
import com.meichis.yndms.model.*;

import java.util.List;

public class ListConverter {

    //Attachment
    @TypeConverter
    public static List<Attachment> str2Att(String json) {
        return new Gson().fromJson(json, new TypeToken<List<Attachment>>() {
        }.getType());
    }

    @TypeConverter
    public static String att2Str(List<Attachment> list) {
        return new Gson().toJson(list);
    }

    //DicDataItem
    @TypeConverter
    public static List<DicDataItem> str2Dic(String json) {
        return new Gson().fromJson(json, new TypeToken<List<DicDataItem>>() {
        }.getType());
    }

    @TypeConverter
    public static String dic2Str(List<DicDataItem> list) {
        return new Gson().toJson(list);
    }


    //InspectTemplate_Item
    @TypeConverter
    public static List<InspectTemplate_Item> str2ITI(String json) {
        return new Gson().fromJson(json, new TypeToken<List<InspectTemplate_Item>>() {
        }.getType());
    }

    @TypeConverter
    public static String iTI2Str(List<InspectTemplate_Item> list) {
        return new Gson().toJson(list);
    }


    //VisitTemplateDetail
    @TypeConverter
    public static List<VisitTemplateDetail> str2VTD(String json) {
        return new Gson().fromJson(json, new TypeToken<List<VisitTemplateDetail>>() {
        }.getType());
    }

    @TypeConverter
    public static String vTD2Str(List<VisitTemplateDetail> list) {
        return new Gson().toJson(list);
    }

    //List<VisitWorkItem>
    @TypeConverter
    public static List<VisitWorkItem> str2VW(String json) {
        return new Gson().fromJson(json, new TypeToken<List<VisitWorkItem>>() {
        }.getType());
    }

    @TypeConverter
    public static String vW2Str(List<VisitWorkItem> list) {
        return new Gson().toJson(list);
    }

    //List<VisitWorkItem_DisplayCheck>
    @TypeConverter
    public static List<VisitWorkItem_DisplayCheck> str2DC(String json) {
        return new Gson().fromJson(json, new TypeToken<List<VisitWorkItem_DisplayCheck>>() {
        }.getType());
    }

    @TypeConverter
    public static String dC2Str(List<VisitWorkItem_DisplayCheck> list) {
        return new Gson().toJson(list);
    }

    //List<VisitWorkItem_EQ>
    @TypeConverter
    public static List<VisitWorkItem_EQ> str2EQ(String json) {
        return new Gson().fromJson(json, new TypeToken<List<VisitWorkItem_EQ>>() {
        }.getType());
    }

    @TypeConverter
    public static String eQ2Str(List<VisitWorkItem_EQ> list) {
        return new Gson().toJson(list);
    }

    //List<VisitWorkItem_Promotion>
    @TypeConverter
    public static List<VisitWorkItem_Promotion> str2P(String json) {
        return new Gson().fromJson(json, new TypeToken<List<VisitWorkItem_Promotion>>() {
        }.getType());
    }

    @TypeConverter
    public static String p2Str(List<VisitWorkItem_Promotion> list) {
        return new Gson().toJson(list);
    }

    //List<InspectResult>
    @TypeConverter
    public static List<InspectResult> str2IR(String json) {
        return new Gson().fromJson(json, new TypeToken<List<InspectResult>>() {
        }.getType());
    }

    @TypeConverter
    public static String iR2Str(List<InspectResult> list) {
        return new Gson().toJson(list);
    }

    //List<FreshScope>
    @TypeConverter
    public static List<FreshScope> str2FS(String json) {
        return new Gson().fromJson(json, new TypeToken<List<FreshScope>>() {
        }.getType());
    }

    @TypeConverter
    public static String fS2Str(List<FreshScope> list) {
        return new Gson().toJson(list);
    }

    //List<TraceCode>
    @TypeConverter
    public static List<TraceCode> str2TC(String json) {
        return new Gson().fromJson(json, new TypeToken<List<TraceCode>>() {
        }.getType());
    }

    @TypeConverter
    public static String tC2Str(List<TraceCode> list) {
        return new Gson().toJson(list);
    }

}
